@extends('layouts.app')

@section('content')
@if (count($errors) > 0)
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif
<div class="col-md-8 col-md-offset-2">
@if($article->exists)
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title" style="height:45px;font-size:20px;"><div style="width:760px;">{{$article->title}}</div><img src="{{url('/')}}/user/img/{{$user->img}}" alt="..." class="img-circle" width="50" height="50" style="position:absolute;top:8px;right:30px;"></h3>
  </div>
  <div class="panel-body" style="height:150px;">
    {{htmlspecialchars($article->content)}}
  </div>
  <div class="panel-footer">
  @can('update', $article)
  <a href="{{route('article.edit',['id' => $article->id])}}" class="btn-sm btn-info">编辑</a>
  @endcan
  <a href="#" class="btn-sm btn-info">分享</a>
  <span class="pull-right">Tags:<span class="label label-default">{{$article->tag}}</span></span>
  </div>
</div>

@if(count($comments) > 0)
@foreach($comments as $k=>$v)
<div class="panel panel-default">
  <div class="panel-body" style="height:100px;">
    {{$v->content}}
  </div>
  <div class="panel-footer" style="height:45px;"><div class="pull-right"><img src="{{url('/').'/user/img/'.$comments_user[$v->u_id]['img']}}" class="img-circle" width="30" height="30" /></div><div class="pull-right" style="margin-right:15px;">{{$comments_user[$v->u_id]['name']}}</div></div>
</div>
@endforeach
@endif

@if(Auth::check())
<form action="{{route('article.comments')}}" method="POST">
<div class="panel panel-default">
  <div class="panel-body">
      <input type="hidden" name="aid" value="{{$article->id}}" />
      <textarea name="content" class="form-control"></textarea>
      {{ csrf_field() }}
  </div>
  <div class="panel-footer"><button type="submit" class="btn btn-primary">跟帖</button></div>
</div>
</form>
@endif
@else
没有找到
@endif
</div>
@endsection